<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户列表</title>
    <link rel="stylesheet" href="../css/userCss.css">
    <script src="../tool/js/jQuery.js"></script>

</head>
<style>
    h1{
        text-align: center;
    }
    table{
        margin: 0 auto;
        text-align:center
    }
    th{

        width: 100px;
    }
</style>
<body>
<h1>用户信息</h1>
<table style="text-align:center " class="table">
    <tr>
        <th>用户名</th>
        <th>身份</th>
    </tr>

</table>
</body>
</html>
<script src="../tool/js/axios.min.js"></script>
<script>
    window.onload = function () {
        axios.get("http://localhost:8080/user/users")
            .then(function (hong) {
                let response = hong.data;
                let table = $(".table");
                console.log(response);
                console.log(response.data.length);

                const userList = response.data;


                if (response.code === 200) {
                    console.log("判断成功")

                    for (let i = 0; i < userList.length; i++) {
                        console.log("进入for循环")
                        const tr =`
                          <tr>
                             <td>${userList[i].username}</td>
                             <td>${userList[i].identity}</td>
                        </rt>`
                        table.append(tr);
                    }
                    console.log("没有进入for循环")

                }
            })
    };
</script>